// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/membercard"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	MemberCard = cMemberCard{}
)

type cMemberCard struct{}

// List 查看会员中心列表
func (c *cMemberCard) List(ctx context.Context, req *membercard.ListReq) (res *membercard.ListRes, err error) {
	list, totalCount, err := service.SysMemberCard().List(ctx, &req.MemberCardListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.MemberCardListModel{}
	}

	res = new(membercard.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新会员中心
func (c *cMemberCard) Edit(ctx context.Context, req *membercard.EditReq) (res *membercard.EditRes, err error) {
	err = service.SysMemberCard().Edit(ctx, &req.MemberCardEditInp)
	return
}

// View 获取指定会员中心信息
func (c *cMemberCard) View(ctx context.Context, req *membercard.ViewReq) (res *membercard.ViewRes, err error) {
	data, err := service.SysMemberCard().View(ctx, &req.MemberCardViewInp)
	if err != nil {
		return
	}

	res = new(membercard.ViewRes)
	res.MemberCardViewModel = data
	return
}

// Status 更新会员中心状态
func (c *cMemberCard) Status(ctx context.Context, req *membercard.StatusReq) (res *membercard.StatusRes, err error) {
	err = service.SysMemberCard().Status(ctx, &req.MemberCardStatusInp)
	return
}
